

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

interface GeneralStack<T>{
	public T push(T item);  
	public T pop();                
	public T peek();             
	public boolean empty();
	public int size();     
}
class ArrayListGeneralStack<T> implements GeneralStack<T>{
	private List<T> list;
	
	public ArrayListGeneralStack(){
		list = new ArrayList<T>();
	}
	public T push(T item){
		if(item==null)
			return null;
		list.add(item);
			return item;
	}
	public T pop(){
		if(list.isEmpty())
			return null;
		return list.remove(list.size()-1);
	}
	public T peek(){
		if(list.isEmpty())
			return null;
		return list.get(list.size()-1);
	}
	
	@Override
	public boolean empty() {
		if(!list.isEmpty())
			return false;
		else 
			return true;
	}


	@Override
	public int size() {
		return list.size();
	}


	@Override
	public String toString() {
		return list.toString();
	}
	
}
class Car{
	private int id;
	private String name;
	
	public Car(int id, String b) {
		super();
		this.id = id;
		this.name = b;
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@Override
	public String toString() {
		return "Car [id=" + id + ", name=" + name + "]";
	}
	
}

public class Sy81 {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		
		while(input.hasNextLine()){
			ArrayListGeneralStack s = new ArrayListGeneralStack();
			String str = input.nextLine();
		if (str.equals("Integer")) {
			int m = input.nextInt();
			int n = input.nextInt();
			System.out.println("Integer Test");
			for (int i = 0; i < m; i++) {
				Integer a = input.nextInt();
				System.out.println("push:" + s.push(a));
			}
			for (int j = 0; j < n; j++) {
				System.out.println("pop:" + s.pop());
			}
			System.out.println(s);
			Integer sum=0;
			while(!s.empty()){
				sum+=(Integer)s.pop();
			}
			System.out.println("sum="+sum);
			System.out.println(s.getClass().getInterfaces()[0]);
		} else if (str.equals("Double")) {
			int m = input.nextInt();
			int n = input.nextInt();
			System.out.println("Double Test");
			for (int i = 0; i < m; i++) {
				Double a = input.nextDouble();
				System.out.println("push:" + s.push(a));
			}
			for (int j = 0; j < n; j++) {
				System.out.println("pop:" + s.pop());
			}
			System.out.println(s);
			Double sum=0.0;
			while(!s.empty()){
				sum+=(Double)s.pop();
			}
			System.out.println("sum="+sum);
			System.out.println(s.getClass().getInterfaces()[0]);
		} else if (str.equals("Car")) {
			int m = input.nextInt();
			int n = input.nextInt();
			System.out.println("Car Test");
			for (int i = 0; i < m; i++) {
				Car car=new Car(input.nextInt(),input.next());
				System.out.println("push:" + s.push(car));
			}
			for (int j = 0; j < n; j++) {
				System.out.println("pop:" + s.pop());
			}
			System.out.println(s);
			if(!s.empty())
				System.out.println(((Car) s.pop()).getName());
			System.out.println(s.getClass().getInterfaces()[0]);
		} else
			System.exit(0);
		input.nextLine();
	}
	}
}
